package com.du.dao.impl;

import com.du.dao.BaseDAO;
import com.du.dao.UserDAO;
import com.du.pojo.User;

/**
 * @author : DuJiabao
 * @Date : 2021/1/28 21:00
 * @Project : bookstore
 * @File : null.java
 * @Desc :
 */
public class UserDAOImpl extends BaseDAO implements UserDAO {
    @Override
    public User queryUserByUsername(String username) {
        return queryForOne(User.class, "Select * from user_info where username=?", username);
    }

    @Override
    public User queryUserByUsernameAndPassword(String username, String password) {
        return queryForOne(User.class, "Select * from user_info where username=? and password=?", username, password);
    }

    @Override
    public int saveUser(User user) {
        return update("INSERT INTO user_info(username, `password`, `email`) VALUES(?, ?, ?);",
                user.getUsername(), user.getPassword(), user.getEmail());
    }
}
